#include "shm.h"


// 创建共享内存
shmid_t shmget(const char* name, size_t size) {
    return CreateFileMapping(
        INVALID_HANDLE_VALUE,
        NULL,
        PAGE_READWRITE,
        0,
        (DWORD)size,
        name
    );
}

// 映射共享内存
void* shmat(shmid_t shmid) {
    return MapViewOfFile(shmid, FILE_MAP_ALL_ACCESS, 0, 0, 0);
}

// 解除共享内存映射
int shmdt(void* shmaddr) {
    return UnmapViewOfFile(shmaddr);
}

// 删除共享内存
int shmctl(shmid_t shmid) {
    return CloseHandle(shmid);
}    